package com.jh.user.service;

import cn.jh.common.exception.ServiceException;
import cn.jh.common.utils.CommonsUtil;
import com.jh.user.business.ChanPayBankBusiness;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
public class ChanPayBankService {
    private static final Logger log = LoggerFactory.getLogger(ChanPayBankService.class);

    private final ChanPayBankBusiness chanPayBankBusiness;

    @Autowired
    public ChanPayBankService(ChanPayBankBusiness chanPayBankBusiness) {
        this.chanPayBankBusiness = chanPayBankBusiness;
    }

    /**
     * 查询畅捷通道支持的银行卡列表
     * @return
     */
    @GetMapping(value = "/v1.0/user/chanpaybank/getchanpaybanklist")
    public Object getChanPayBankList() {
        try {
            List<Map<String, Object>> list = chanPayBankBusiness.getChanPayBankList();
            return CommonsUtil.returnSuccess("查询成功！", list);
        } catch (ServiceException e) {
            e.printStackTrace();
            return CommonsUtil.returnError(e.getMessage());
        } catch (Exception e) {
            e.printStackTrace();
            return CommonsUtil.returnError("服务器异常，请稍后再试！");
        }
    }
}
